# encoding=utf-8
import pandas as pd
from application.logging import logger


def dataprocesses(df_):
    list_weather = []
    df_weather_list = list(df_['weather'])
    logger.info(df_weather_list)
    # for - begin
    for i in range(len(df_)):
        weather_str = df_weather_list[i]
        if weather_str == "晴":
            list_weather.append(1)
        elif weather_str == "多云":
            list_weather.append(2)
        elif weather_str == "阴":
            list_weather.append(3)
        elif "雨" in weather_str:
            list_weather.append(4)
        elif "雪" in weather_str:
            list_weather.append(5)
        elif "雾" in weather_str:
            list_weather.append(6)
        elif "霾" in weather_str:
            list_weather.append(7)
        else:
            list_weather.append(8)
        pass
    # for - finished
    # 返回数据
    return list_weather
    pass


if __name__ == '__main__':
    # 测试数据
    d = {"weather": ["晴", "雾", "多云", "阴", "雨", "雪", "雾", "霾", "其他"]}
    # 封装数据
    df = pd.DataFrame(data=d)
    logger.info(df)
    list_weather = dataprocesses(df)
    logger.info(list_weather)
    pass
